package com.mnyc.research.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mnyc.common.annotation.Log;
import com.mnyc.common.core.controller.BaseController;
import com.mnyc.common.core.domain.AjaxResult;
import com.mnyc.common.enums.BusinessType;
import com.mnyc.research.domain.JyResearchGroup;
import com.mnyc.research.service.IJyResearchGroupService;
import com.mnyc.common.utils.poi.ExcelUtil;
import com.mnyc.common.core.page.TableDataInfo;

/**
 * 教研组Controller
 *
 * @author wdy
 * @date 2025-08-06
 */
@RestController
@RequestMapping("/research/jyResearchGroup")
public class JyResearchGroupController extends BaseController
{
    @Autowired
    private IJyResearchGroupService jyResearchGroupService;

    /**
     * 查询教研组列表
     */
    @PreAuthorize("@ss.hasPermi('research:jyResearchGroup:list')")
    @GetMapping("/list")
    public TableDataInfo list(JyResearchGroup jyResearchGroup)
    {
        startPage();
        List<JyResearchGroup> list = jyResearchGroupService.selectJyResearchGroupList(jyResearchGroup);
        return getDataTable(list);
    }

    /**
     * 导出教研组列表
     */
    @PreAuthorize("@ss.hasPermi('research:jyResearchGroup:export')")
    @Log(title = "教研组", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JyResearchGroup jyResearchGroup)
    {
        List<JyResearchGroup> list = jyResearchGroupService.selectJyResearchGroupList(jyResearchGroup);
        ExcelUtil<JyResearchGroup> util = new ExcelUtil<JyResearchGroup>(JyResearchGroup.class);
        util.exportExcel(response, list, "教研组数据");
    }

    /**
     * 获取教研组详细信息
     */
    @PreAuthorize("@ss.hasPermi('research:jyResearchGroup:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(jyResearchGroupService.selectJyResearchGroupById(id));
    }

    /**
     * 新增教研组
     */
    @PreAuthorize("@ss.hasPermi('research:jyResearchGroup:add')")
    @Log(title = "教研组", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JyResearchGroup jyResearchGroup)
    {
        return toAjax(jyResearchGroupService.insertJyResearchGroup(jyResearchGroup));
    }

    /**
     * 修改教研组
     */
    @PreAuthorize("@ss.hasPermi('research:jyResearchGroup:edit')")
    @Log(title = "教研组", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JyResearchGroup jyResearchGroup)
    {
        return toAjax(jyResearchGroupService.updateJyResearchGroup(jyResearchGroup));
    }

    /**
     * 删除教研组
     */
    @PreAuthorize("@ss.hasPermi('research:jyResearchGroup:remove')")
    @Log(title = "教研组", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(jyResearchGroupService.deleteJyResearchGroupById(id));
    }

}
